Skip to content

explorer: fix halo cutoff over terrain (disableDepthTestDistance)#181

Merged
rdhyee merged 1 commit into
isamplesorg:mainfrom
rdhyee:explorer-halo-depth-fix
May 9, 2026
Merged

explorer: fix halo cutoff over terrain (disableDepthTestDistance)#181
rdhyee merged 1 commit into
isamplesorg:mainfrom
rdhyee:explorer-halo-depth-fix

Conversation

@rdhyee
Copy link
Copy Markdown
Contributor

@rdhyee rdhyee commented May 9, 2026

Summary

Hotfix for the halo regression introduced in #180.

The white halos exposed a pre-existing Cesium terrain depth-test artifact: PointPrimitives are positioned at altitude=0, so wherever Cesium World Terrain has elevation, the front face of the terrain mesh occludes part of the sprite. Without halos, that truncation read as a slightly smaller dot. With halos, the white ring made the cut glaringly obvious — appearing as crescents — and over higher terrain the sprite vanishes entirely.

Reported view: explorer.html#v=1&lat=33.2706&lng=-86.2375&alt=311435 (Birmingham, AL hill country) — many dots showed only as half-moon halos or were entirely missing.

Fix

Add disableDepthTestDistance: Number.POSITIVE_INFINITY to all three PointPrimitive.add() sites (h3Points x2 cluster-mode + samplePoints x1). This matches the existing pattern already used by pointLabel at line 843 — points render always-on-top regardless of intervening terrain.

Trade-off

With depth test off, points on the far side of the globe could in principle bleed through. In practice at the zoom levels users hit (regional → world), the cluster aggregation hides this, and Cesium's frustum culling still removes truly back-facing primitives. Standard fix per Cesium docs.

Verified locally

quarto render + Playwright at the reported camera (lat=33.27, lng=-86.24, alt=311km):

check result
Dots render as full circles, no crescents
Dots over high terrain that were missing ✓ visible
Halos still present (a11y win preserved)

Test plan

  • Visit https://isamples.org/explorer.html#v=1&lat=33.2706&lng=-86.2375&alt=311435&heading=360.0 and confirm full-circle dots replace the previous crescents
  • Other terrain-heavy regions: any mountainous area at street zoom

🤖 Generated with Claude Code

The white halos added in isamplesorg#180 made a pre-existing terrain depth-test artifact
visible: dots positioned at altitude=0 get partly (or entirely) occluded by
Cesium World Terrain wherever land elevation rises. Without halos, the
truncation read as a smaller dot. With halos, the white ring exposes the cut
as a crescent — and over higher terrain, the whole sprite disappears.

Fix: add `disableDepthTestDistance: Number.POSITIVE_INFINITY` to all three
PointPrimitive add() sites (h3Points x2 + samplePoints), matching the existing
pattern used by `pointLabel` (line 843) — points render always-on-top
regardless of intervening terrain.

Reported view: explorer.html#v=1&lat=33.27&lng=-86.24&alt=311435 (Birmingham
AL hill country). Verified locally — dots render as full circles; previously-
missing dots over higher terrain are visible again.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rdhyee rdhyee merged commit d681758 into isamplesorg:main May 9, 2026
1 check passed
rdhyee added a commit that referenced this pull request May 9, 2026
rdhyee added a commit that referenced this pull request May 10, 2026
…terrain (closes #185) (#198)

Cluster and sample point primitives are placed at altitude=0 (the WGS84
ellipsoid surface). With Cesium world terrain enabled, terrain mesh in
hilly regions (Troodos in Cyprus, hill country around Birmingham AL,
etc.) rises hundreds to thousands of meters above ellipsoid — so points
at altitude=0 are physically *underground* in those regions and get
depth-culled by Cesium's standard per-pixel depth test.

The fix is one new property at each of the three .add() call sites:

  disableDepthTestDistance: POINT_DEPTH_TEST_DISTANCE  // 2.0e6 = 2,000 km

Bypass scope: only when the camera is closer than 2,000 km, which covers
every realistic interactive altitude (point mode <120 km, res8 cluster
up to ~300 km, res6 up to ~3,000 km — the upper end is technically
outside the bypass but at that altitude dots are tiny anyway).

Why bounded (2.0e6) and not POSITIVE_INFINITY: PR #181 used Infinity and
caused back-side-of-globe primitive bleed-through plus broke pickability
(was reverted via #183). A 2,000 km bound preserves globe-ellipsoid
occlusion at long range while bypassing terrain occlusion at every
interactive zoom.

Hypothesis source: Codex review of #185 identified sea-level placement
as the most likely root cause. Confirmed experimentally by runtime-
patching the live deploy:

  T0 baseline (no fix)                          Cyprus interior: ~0 dots
  T1 swap to EllipsoidTerrainProvider           minor improvement
  T2 raise primitives to height=5000m           significant improvement
  T3 disableDepthTestDistance: 2.0e6 (this PR)  significant, equivalent
                                                to T2, no back-side bleed

Closes #185.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant